{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To import chemview you can write and execute the following code in a cell:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from chemview import MolecularViewer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To display a benzene molecule we need at least two pieces of information:\n",
    "\n",
    "1. The atomic types\n",
    "2. The atomic coordinates\n",
    "3. The bonds between atoms\n",
    "\n",
    "For the scope of this tutorial, the information were extracted from here. You can use a chemical package (like mdtraj or chemlab) to read the coordinates of your molecules.\n",
    "\n",
    "We define the coordinates as a numpy array, the atomic types as a list of strings and the bonds as a list of start, end tuples.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "coordinates = np.array([[0.00, 0.13, 0.00], [0.12, 0.07, 0.00], [0.12,-0.07, 0.00],\n",
    "                       [0.00,-0.14, 0.00], [-0.12,-0.07, 0.00],[-0.12, 0.07, 0.00],\n",
    "                       [ 0.00, 0.24, 0.00], [ 0.21, 0.12, 0.00], [ 0.21,-0.12, 0.00],\n",
    "                       [ 0.00,-0.24, 0.00], [-0.21,-0.12, 0.00],[-0.21, 0.12, 0.00]])\n",
    "atomic_types = ['C', 'C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H']\n",
    "bonds = [(0, 6), (1, 7), (2, 8), (3, 9), (4, 10), (5, 11),\n",
    "         (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 0)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can pass those to the class MolecularViewer and call the method lines to render the molecule as a wireframe:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "mv = MolecularViewer(coordinates, topology={'atom_types': atomic_types,\n",
    "                                            'bonds': bonds})\n",
    "mv.ball_and_sticks()\n",
    "mv"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can rotate (left click), pan(right click) and zoom (wheel) to visualize your molecules."
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
